Skip to content

Update gson date format for serializing/deserializing Date in MS stats#11506

Merged
weizhouapache merged 5 commits into
apache:4.20from
shapeblue:mgmt-server-status-date-format-update
Sep 22, 2025
Merged

Update gson date format for serializing/deserializing Date in MS stats#11506
weizhouapache merged 5 commits into
apache:4.20from
shapeblue:mgmt-server-status-date-format-update

Conversation

@sureshanaparti

@sureshanaparti sureshanaparti commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Description

This PR updates gson date format for serializing/deserializing Date in MS stats (across multiple management servers).

The DateFormat is set to default system locale if not set, and serialization/deserialization fails when management server nodes have different locale/timezones.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Aug 25, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.17%. Comparing base (38006b2) to head (b1b0087).
⚠️ Report is 13 commits behind head on 4.20.

Files with missing lines Patch % Lines
...src/main/java/com/cloud/server/StatsCollector.java 50.00% 3 Missing ⚠️
...m/cloud/server/ManagementServerHostStatsEntry.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #11506   +/-   ##
=========================================
  Coverage     16.17%   16.17%           
- Complexity    13297    13298    +1     
=========================================
  Files          5656     5656           
  Lines        498136   498154   +18     
  Branches      60432    60441    +9     
=========================================
+ Hits          80583    80590    +7     
- Misses       408585   408589    +4     
- Partials       8968     8975    +7     
Flag Coverage Δ
uitests 4.00% <ø> (+<0.01%) ⬆️
unittests 17.03% <42.85%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14724

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-14113)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR standardizes the date format for Gson serialization/deserialization across CloudStack's management server statistics functionality. The change ensures consistent date formatting when exchanging statistics data between multiple management servers.

  • Updates the StatsCollector's Gson instance to use a specific date format pattern
  • Applies the same date format to the global Gson configuration in GsonHelper
  • Simplifies JSON deserialization by removing unnecessary TypeToken usage

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
server/src/main/java/com/cloud/server/StatsCollector.java Updates Gson initialization with date format, simplifies deserialization, and removes unused import
core/src/main/java/com/cloud/serializer/GsonHelper.java Adds consistent date format to the default Gson configuration
Comments suppressed due to low confidence (1)

server/src/main/java/com/cloud/server/StatsCollector.java:163

  • [nitpick] The variable initialization change from 'null' to uninitialized is unnecessary since the variable is immediately assigned in the try block. The original initialization provided better clarity about the intended flow.
import com.cloud.vm.dao.VmStatsDao;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread server/src/main/java/com/cloud/server/StatsCollector.java Outdated
@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@apache apache deleted a comment from blueorangutan Aug 26, 2025
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 14728

@DaanHoogland

Copy link
Copy Markdown
Contributor

code looks good @sureshanaparti , but can you update with a test procedure? (or automated test)

Comment thread core/src/main/java/com/cloud/serializer/GsonHelper.java Outdated
@sureshanaparti sureshanaparti force-pushed the mgmt-server-status-date-format-update branch from 34bab74 to 8a451a4 Compare September 11, 2025 10:43
@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@sureshanaparti sureshanaparti marked this pull request as ready for review September 11, 2025 10:43
@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 14953

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sureshanaparti
codewise it looks good to me

the GsonHelper class is being used in many classes, need to be careful

@weizhouapache

Copy link
Copy Markdown
Member

@weizhouapache the issue rarely occurs, mostly it is noticed when management server nodes with different locale/timezones. You'll see exception like below. The DateFormat is set to default system locale if not set, and serialization/deserialization fails when nodes have different locale/timezones

thanks @sureshanaparti
It seems to be a rare issue indeed.

since the date format is used in many scenarios (mgmt to mgmt, mgmt to agent, acs to 3rd parties, etc), it is difficult to test if it works or breaks some functionalities, I would prefer to leave it for next release.

cc @harikrishna-patnala @sureshanaparti @DaanHoogland

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@weizhouapache the issue rarely occurs, mostly it is noticed when management server nodes with different locale/timezones. You'll see exception like below. The DateFormat is set to default system locale if not set, and serialization/deserialization fails when nodes have different locale/timezones

thanks @sureshanaparti It seems to be a rare issue indeed.

since the date format is used in many scenarios (mgmt to mgmt, mgmt to agent, acs to 3rd parties, etc), it is difficult to test if it works or breaks some functionalities, I would prefer to leave it for next release.

cc @harikrishna-patnala @sureshanaparti @DaanHoogland

upto @weizhouapache there'll be issues during deserialization when date format doesn't match.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15020

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15029

@weizhouapache weizhouapache added this to the 4.20.2 milestone Sep 18, 2025
@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15087

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15092

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@weizhouapache

Copy link
Copy Markdown
Member

@sureshanaparti
you can assign to me if you need testing

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-14384)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52921 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11506-t14384-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@weizhouapache

Copy link
Copy Markdown
Member

tested ok

  • the logs show date like
"collectionTime": "2025-09-22T10:18:58+0000",
"systemBootTime": "2025-09-08T11:45:34+0000",
  • mshost_peer is updated without issue
  • cmk list managementserversmetrics shows the date (collection time, last boot/start/stop) without issue

@weizhouapache weizhouapache merged commit 12513e1 into apache:4.20 Sep 22, 2025
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the mgmt-server-status-date-format-update branch September 24, 2025 07:06
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Oct 17, 2025
… MS stats (apache#11506)

* Update gson date format for serializing/deserializing Date in MS stats (across multiple management servers)

* review

* review comments, and unit tests

* added unit test with different date format

* Use separate Gson for MS stats serialization/deserialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants